// Tags:
#include <cstdio>
#include <unordered_map>

typedef long long ll;
const int N = 7, M = 151;
int n, m, k[N], p[N], ans, lim;
ll f[N][M];
std::unordered_map<ll, int> map;

inline ll qpow(ll base, int index) {
  ll res = 1;
  while (index) {
    if (index & 1) res = res * base;
    base = base * base;
    index >>= 1;
  }
  return res;
}

void solve(int step, ll sum, bool typ) {
  if (step > lim) {
    if (typ) {
      std::unordered_map<ll, int>::iterator iter;
      if ((iter = map.find(-sum)) != map.end()) ans += iter->second;
    } else
      ++map[sum];
    return;
  }
  for (int i = 1; i <= m; ++i) { solve(step + 1, sum + f[step][i], typ); }
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("math.in", "r", stdin);
  freopen("math.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) { scanf("%d%d", &k[i], &p[i]); }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) { f[i][j] = 1ll * k[i] * qpow(j, p[i]); }
  }
  lim = n >> 1;
  solve(1, 0, false);
  lim = n;
  solve((n >> 1) + 1, 0, true);
  printf("%d", ans);
  return 0;
}